<template>
  <el-dialog
    v-model="dialogVisible"
    width="400px"
    style="
      background: #222222;
      border-radius: 9px;
      border: 1px solid rgba(255, 255, 255, 0.5);
      padding: 0;
    "
    :modal="false"
    :before-close="close"
    align-center
    @close="close"
  >
    <template #header>
      <div class="title">麦位变更</div>
    </template>
    <template #default>
      <div class="dialog-content">
        <el-radio-group v-model="inputValue">
          <el-radio :label="0" />
          <el-radio :label="4" />
          <el-radio :label="8" />
          <el-radio :label="12" />
        </el-radio-group>
        <div style="font-size: 10px; color: rgba(255, 255, 255, 0.4); margin-top: 10px">
          (麦位数量不包含房主 修改后所有成员将强制下麦)
        </div>
      </div>
      <div class="btns">
        <span class="btn" @click="close">取消</span>
        <span class="btn" style="color: #ff4e6c" @click="handleSubmit">确认</span>
      </div>
    </template>
  </el-dialog>
</template>
<script lang="ts" setup>
import { ref } from "vue";

const { updateMicrophone } = inject("microphone");
const dialogVisible = ref(false);
const inputValue = ref(0); // 麦位数量
// 显示
const show = (status: number) => {
  inputValue.value = status;
  dialogVisible.value = true;
};

// 关闭前的回调
const close = () => {
  dialogVisible.value = false;
  inputValue.value = 0;
};
const handleSubmit = () => {
  updateMicrophone(inputValue.value);
  close();
};

defineExpose({ show, close });
</script>
<style lang="scss" scoped>
.title {
  padding: 15px 32px 0px;
  font-size: 16px;
  color: #fff;
}
.dialog-content {
  border-top: 1px solid rgba(216, 216, 216, 0.5);
  border-bottom: 1px solid rgba(216, 216, 216, 0.5);
  padding: 50px 20px;
  color: #fff;
  text-align: center;
}
.btns {
  padding: 14px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  .btn {
    padding: 7px 16px;
    font-size: 12px;
    color: #8a8a8a;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    cursor: default;
  }
}
::v-deep .el-form-item__label {
  color: #fff;
}
::v-deep .el-radio__label {
  color: #fff;
}
</style>
